package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.OrderOperationlog;
import com.ktgj.service.service.IOrderOperationlogService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 订单操作记录Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/operationlog")
public class OrderOperationlogController extends BaseController
{
    @Autowired
    private IOrderOperationlogService orderOperationlogService;

    /**
     * 查询订单操作记录列表
     */
    @PreAuthorize(hasPermi = "service:operationlog:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderOperationlog orderOperationlog)
    {
        startPage();
        List<OrderOperationlog> list = orderOperationlogService.selectOrderOperationlogList(orderOperationlog);
        return getDataTable(list);
    }

    /**
     * 导出订单操作记录列表
     */
    @PreAuthorize(hasPermi = "service:operationlog:export")
    @Log(title = "订单操作记录 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderOperationlog orderOperationlog) throws IOException
    {
        List<OrderOperationlog> list = orderOperationlogService.selectOrderOperationlogList(orderOperationlog);
        ExcelUtil<OrderOperationlog> util = new ExcelUtil<OrderOperationlog>(OrderOperationlog.class);
        util.exportExcel(response, list, "订单操作记录 数据");
    }

    /**
     * 获取订单操作记录详细信息
     */
    @PreAuthorize(hasPermi = "service:operationlog:query")
    @GetMapping(value = "/{operationId}")
    public AjaxResult getInfo(@PathVariable("operationId") Long operationId)
    {
        return AjaxResult.success(orderOperationlogService.selectOrderOperationlogById(operationId));
    }

    /**
     * 新增订单操作记录
     */
    @PreAuthorize(hasPermi = "service:operationlog:add")
    @Log(title = "订单操作记录 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderOperationlog orderOperationlog)
    {
        return toAjax(orderOperationlogService.insertOrderOperationlog(orderOperationlog));
    }

    /**
     * 修改订单操作记录
     */
    @PreAuthorize(hasPermi = "service:operationlog:edit")
    @Log(title = "订单操作记录 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderOperationlog orderOperationlog)
    {
        return toAjax(orderOperationlogService.updateOrderOperationlog(orderOperationlog));
    }

    /**
     * 删除订单操作记录
     */
    @PreAuthorize(hasPermi = "service:operationlog:remove")
    @Log(title = "订单操作记录 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operationIds}")
    public AjaxResult remove(@PathVariable Long[] operationIds)
    {
        return toAjax(orderOperationlogService.deleteOrderOperationlogByIds(operationIds));
    }
}
